// JavaScript Document

/*导航栏菜单功能*/
function jddhShow(){
	switch (true) {		
		default :
			$("#nav li").attr("class","");
			$(".nav_lishw .v a").attr("class","sele");
			$("#tmenu").hide();
	} 
	
	$("#nav li").hover(
		function(){
			clearTimeout(setTimeout("0")-1);
			$("#nav .kind_menu").hide(); 
			$("#nav li .v .sele").attr("class","shutAhover");
			$(this).attr("id","nav_hover")
			$("#nav_hover .v a").attr("class","sele");
			$("#nav_hover .kind_menu").show();
			$("#tmenu").show(); 
		},
		function(){
			if($(this).attr("class") != "nav_lishw"){
				$("#nav_hover .v .sele").attr("class","");
				$("#nav_hover .kind_menu").hide(); 
				$("#tmenu").hide();
			}
			$(this).attr("id","")
			$("#nav li .v .shutAhover").attr("class","sele");
			setTimeout(function(){
				$(".nav_lishw .kind_menu").show();
				$(".nav_lishw .v a").attr("class","sele");
			},50); 
		}
	);
}

//头部的显示与隐藏
function head_show(){
	var tcPhone=$("#tcPhone");
	var tcPhone_info=$("#tcPhone_info");
	var servicePhone=$("#servicePhone");
	var servicePhone_info=$("#servicePhone_info");
	var topJoinTc=$("#topJoinTc");
	var topJoinTc_info=$("#topJoinTc_info");
	
	tcPhone.mouseover(function(e) {
		tcPhone_info.css("display","block");
		tcPhone.css("background","#ccc");
		$("#tcPhone a").css("color","#FF7800");
		$("#tcPhone img").attr("src","images/arrow.png");
	});
	tcPhone.mouseout(function(e) {
		tcPhone_info.css("display","none");
		tcPhone.css("background","");
		$("#tcPhone a").css("color","");
		$("#tcPhone img").attr("src","images/arrow2.png");
	});
	servicePhone.mouseover(function(e) {
		servicePhone_info.css("display","block");
		servicePhone.css("background","#ccc");
		$(".servicePhone_a").css("color","#FF7800");
		$("#servicePhone img").attr("src","images/arrow.png");
	});
	servicePhone.mouseout(function(e) {
		servicePhone_info.css("display","none");
		servicePhone.css("background","");
		$(".servicePhone_a").css("color","");
		$("#servicePhone img").attr("src","images/arrow2.png");
	});
	topJoinTc.mouseover(function(e) {
		topJoinTc_info.css("display","block");
		topJoinTc.css("background","#ccc");
		$(".topJoinTc_a").css("color","#FF7800");
		$("#topJoinTc img").attr("src","images/arrow.png");
	});
	topJoinTc.mouseout(function(e) {
		topJoinTc_info.css("display","none");
		topJoinTc.css("background","");
		$(".topJoinTc_a").css("color","");
		$("#topJoinTc img").attr("src","images/arrow2.png");
	});	
}

/**
 * 获取当前用户登录信息
 */
function getUserLoginInfo(){
	$.post("loginServlet?t="+new Date(),{op:'getUserLoginInfo'},function(data){
		var str="";
		if(isNaN(data)){		
			str='<span>您好！</span><a class="login" href="user.html" id="currentUserInfo">'+data.loginUserInfo.uname+'</a> <a class="register" href="javascript:userOutLogin()">退出</a>';
		}else{
			str='<span>您好，欢迎使用LY.com访问同程！</span><a class="login" href="login.html">登录</a><a class="register" href="register.html">注册</a>';
		}
		$("#userInfoShow").html(str);
	},"json");
}

/**
 * 获取当前用户登录信息(预订时的样式)
 */
function getUserLoginInfos(){
	$.post("loginServlet?t="+new Date(),{op:'getUserLoginInfo'},function(data){
		var str="";
		if(isNaN(data)){		
			str='<li class="check_head_right_1"><span style="color:red; font-size:16px;">当前用户：</span><a href="user.html" class="login" id="currentUserInfo">'+data.loginUserInfo.uname+'</a></li>';
		}
		$("#userInfoShow").html(str);
	},"json");
}

/**
 * 获取当前用户登录信息(user.html页面)
 */
function getUserLoginInfoss(){
	$.post("loginServlet?t="+new Date(),{op:'getUserLoginInfo'},function(data){
		var str="";
		if(isNaN(data)){		
			str='<span>您好！</span><a class="login" href="user.html" id="currentUserInfo">'+data.loginUserInfo.uname+'</a> <a class="register" href="javascript:userOutLogins()">退出</a>';
		}
		$("#userInfoShow").html(str);
	},"json");
}

//退出登录(user.html页面)
function userOutLogins(){
	$.post("loginServlet?t="+new Date(),{op:"userOutLogin"},function(data){
		data=parseInt($.trim(data));
		if(data==1){
			window.location.href="index.html";
		}
	});
}


//退出登录
function userOutLogin(){
	$.post("loginServlet?t="+new Date(),{op:"userOutLogin"},function(data){
		data=parseInt($.trim(data));
		if(data==1){
			str='<span>您好，欢迎使用LY.com访问同程！</span><a class="login" href="login.html">登录</a><a class="register" href="register.html">注册</a>';
			$("#userInfoShow").html(str);
		}
	});
}

//点击进入我的订单
function EntryOrder(){
	var login=$(".login").html();
	if(login=="登录"){
		alert("请登录...");
		window.location.href="login.html";
	}else{
		window.location.href="user.html";
	}
}

function ShowEdit(){
	var login=$(".login").html();
	if(login=="登录"){
		alert("请登录...");
		window.location.href="login.html";
	}else{
		window.location.href="edit.html";
	}
}

function ShowMyPage(){
	var login=$(".login").html();
	if(login=="登录"){
		alert("请登录...");
		window.location.href="login.html";
	}else{
		window.location.href="mypage.html";
	}
}